<template>
    <view>
        <view class="title">{{title}}</view>
        <view class="content_card">
            <view class="content_line" :key="k" v-for="(v,k) in infoMap">
                <text class="">{{k}}</text>
                <text class="" @click="v_click(v)" @longpress="v_longclick(v)">{{v}}</text>
            </view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {

            };
        },
        props: {
            title: String,
            infoMap: Object,
        },
        onReady: function() {
            // console.log(this.infoMap)
        },
        methods: {
            v_longclick(v) {
                uni.setClipboardData({
                    data: v,
                });
                uni.showToast({
                    duration: 2000,
                    title: "复制成功",
                    icon: "success",
                })
            },
            v_click(v) {
                // console.log(v);
                if (v.indexOf("http") == 0) {
                    // http
                    uni.navigateTo({
                        url: "../urlsee/urlsee?goto=" + v
                    })
                } else if (v.indexOf("@") > 0) {
                    // email
                    uni.navigateTo({
                        url: "../urlsee/urlsee?see=" + v
                    })
                } else if (v.length == 11) {
                    // phone
                    uni.makePhoneCall({
                        phoneNumber: v,
                    })
                } else {
                    uni.navigateTo({
                        url: "../urlsee/urlsee?see=" + v
                    })
                }
            }
        },
    }
</script>

<style lang="scss">
    .title {
        padding: 20upx 0upx 5upx 0upx;
        color: gray;
    }

    .content_card {
        background-color: white;
        color: black;
        border-top: 1px solid lightgray;
        border-bottom: 1px solid lightgray;
        margin: 0upx -40upx;
        padding: 0px 20px;
    }

    .content_line {
        line-height: 1.6rem;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        border-bottom: 1px solid lightgray;
    }

    .content_line>text:nth-child(2) {
        color: gray;
    }

    .content_line>text:nth-child(1) {
        font-weight: bold;
    }

    .content_line:nth-last-child(1) {
        border-bottom: 0px;
    }
</style>
